/* GUI CONVERTED from rcsdpint.p (converter v1.76) Sun Feb 24 20:08:33 2002 */
/* rcsdpint.p - Release Management Customer Schedules                   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.9 $                                                        */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 7.0    LAST MODIFIED: 01/29/92           BY: WUG *F110*    */
/* REVISION: 7.0    LAST MODIFIED: 03/18/92           BY: WUG *F312*    */
/* REVISION: 7.0    LAST MODIFIED: 03/26/92           BY: WUG *F323*    */
/* REVISION: 7.0    LAST MODIFIED: 06/17/92           BY: WUG *FXXX*    */
/* REVISION: 7.3    LAST MODIFIED: 12/18/92           BY: WUG *G462*    */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane      */
/* REVISION: 8.6E   LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan     */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan     */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* myb            */
/* REVISION: 9.1    LAST MODIFIED: 09/06/00   BY: *N0RG* Rajinder Kamra */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.9 $    BY: Anitha Gopal          DATE: 02/17/02  ECO: *N19G*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/
/* INTERPRETS SHIP/DELIVERY PATTERN CODE */

{mfdeclre.i}
{gplabel.i}
define new shared variable wk_mon_dt as date.
define new shared variable days_of_week as character.

define shared variable ship_dlvy_code as character.
define shared variable interval_code as character.
define shared variable req_dt as date.
define shared variable req_qty as decimal.
define shared variable week_offset as integer.
define shared variable shipto_calid as character.

/* OUTPUT PARAMETERS: */
define shared variable resch_ct as integer.
define shared variable resch_dt as date extent 999 no-undo.
define shared variable resch_qty as decimal extent 999 no-undo.
define shared variable working_hours as decimal extent 999 no-undo.
define shared variable resch_stat as character.

define variable mth_1st_mon_dt as date.
define variable prior_mth_1st_mon_dt as date.
define variable prior_wk_mon_dt as date.
define variable work_dt as date.
define variable work_sum as decimal.
define variable i as integer no-undo.
define variable work_month as integer.
define variable work_year as integer.

assign
   /* FIND FIRST MONDAY OF THE MONTH WE ARE IN */
   mth_1st_mon_dt = date(month(req_dt),1,year(req_dt))
   mth_1st_mon_dt = mth_1st_mon_dt + ((9 - weekday(mth_1st_mon_dt)) modulo 7)

   /* FIND FIRST MONDAY OF THE PRIOR MONTH */
   prior_mth_1st_mon_dt =
      date(month(mth_1st_mon_dt - 10),1,year(mth_1st_mon_dt - 10))

   prior_mth_1st_mon_dt =
      prior_mth_1st_mon_dt + ((9 - weekday(prior_mth_1st_mon_dt)) modulo 7)

   /* FIND MONDAY OF THE WEEK WE ARE IN (MONDAY-SUNDAY WEEK) */
   wk_mon_dt       = req_dt - ((weekday(req_dt) + 5) modulo 7)
   prior_wk_mon_dt = wk_mon_dt - 7

   resch_ct     = 1
   resch_qty[1] = req_qty
   resch_dt[1]  = req_dt
   resch_stat   = "".

if interval_code = "d"
then do:
   /* DISCRETE QUANTITIES */

   if ship_dlvy_code = "01"
   or ship_dlvy_code = "1"
   then do:
      /* 1ST WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt
      then
         resch_dt[1] = mth_1st_mon_dt.
      else
          resch_dt[1] = prior_mth_1st_mon_dt.
   end. /* IF ship_dlvy_code = "01" */
   else
   if ship_dlvy_code = "02"
   or ship_dlvy_code = "2"
   then do:
      /* 2ND WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt + 7
      then
         resch_dt[1] = mth_1st_mon_dt + 7.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 7.
   end. /* IF ship_dlvy_code = "02" */
   else
   if ship_dlvy_code = "03"
   or ship_dlvy_code = "3"
   then do:
      /* 3RD WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt + 14
      then
         resch_dt[1] = mth_1st_mon_dt + 14.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 14.
   end. /* IF ship_dlvy_code = "03" */
   else
   if ship_dlvy_code = "04"
   or ship_dlvy_code = "4"
   then do:
      /* 4TH WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt + 21
      then
         resch_dt[1] = mth_1st_mon_dt + 21.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 21.
   end. /* IF ship_dlvy_code = "04" */
   else
   if ship_dlvy_code = "05"
   or ship_dlvy_code = "6"
   then do:
      /* 1ST *OR* 3RD WEEKS OF MONTH */
      if req_dt >= mth_1st_mon_dt + 14
      then
         resch_dt[1] = mth_1st_mon_dt + 14.
      else
      if req_dt >= mth_1st_mon_dt
      then
         resch_dt[1] = mth_1st_mon_dt.
      else
      if req_dt >= prior_mth_1st_mon_dt + 14
      then
         resch_dt[1] = prior_mth_1st_mon_dt + 14.
      else
         resch_dt[1] = prior_mth_1st_mon_dt.
   end. /* IF ship_dlvy_code = "05" */
   else
   if ship_dlvy_code = "06"
   or ship_dlvy_code = "7"
   then do:
      /* 2ND *OR* 4TH WEEKS OF MONTH */
      if req_dt >= mth_1st_mon_dt + 21
      then
         resch_dt[1] = mth_1st_mon_dt + 21.
      else
      if req_dt >= mth_1st_mon_dt + 7
      then
         resch_dt[1] = mth_1st_mon_dt + 7.
      else
      if req_dt >= prior_mth_1st_mon_dt + 21
      then
         resch_dt[1] = prior_mth_1st_mon_dt + 21.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 7.
   end. /* IF ship_dlvy_code = "06" */
   else
   if ship_dlvy_code = "07"
   then
      /* FIRST DAY OF MONTH */
      resch_dt[1] = date(month(req_dt),1,year(req_dt)).
   else
   if ship_dlvy_code = "10"
   or ship_dlvy_code = "A"
   then do:
      /* MONDAY THRU FRIDAY */
      resch_dt[1] = req_dt.
      if weekday(req_dt) = 7
      then
         resch_dt[1] = resch_dt[1] - 1.
      else
      if weekday(req_dt) = 1
      then
         resch_dt[1] = resch_dt[1] - 2.
   end. /* IF ship_dlvy_code = "10" */
   else
   if ship_dlvy_code = "11"
   or ship_dlvy_code = "B"
   then do:
      /* MONDAY THRU SATURDAY */
      resch_dt[1] = req_dt.
      if weekday(req_dt) = 1
      then
         resch_dt[1] = resch_dt[1] - 1.
   end. /* IF ship_dlvy_code = "11" */
   else
   if ship_dlvy_code = "12"
   or ship_dlvy_code = "D"
   then
      /* MONDAY */
      resch_dt[1] = wk_mon_dt.
   else
   if ship_dlvy_code = "13"
   or ship_dlvy_code = "E"
   then do:
      /* TUESDAY */
      resch_dt[1] = wk_mon_dt + 1.
      if req_dt < resch_dt[1]
      then
         resch_dt[1] = resch_dt[1] - 7.
   end. /* IF ship_dlvy_code = "13" */
   else
   if ship_dlvy_code = "14"
   or ship_dlvy_code = "F"
   then do:
      /* WEDNESDAY */
      resch_dt[1] = wk_mon_dt + 2.
      if req_dt < resch_dt[1]
      then
         resch_dt[1] = resch_dt[1] - 7.
   end. /* IF ship_dlvy_code = "14" */
   else
   if ship_dlvy_code = "15"
   or ship_dlvy_code = "G"
   then do:
      /* THURSDAY */
      resch_dt[1] = wk_mon_dt + 3.
      if req_dt < resch_dt[1]
      then
         resch_dt[1] = resch_dt[1] - 7.
   end. /* IF ship_dlvy_code = "15" */
   else
   if ship_dlvy_code = "16"
   or ship_dlvy_code = "H"
   then do:
      /* FRIDAY */
      resch_dt[1] = wk_mon_dt + 4.
      if req_dt < resch_dt[1]
      then
         resch_dt[1] = resch_dt[1] - 7.
   end. /* IF ship_dlvy_code = "16" */
   else
   if ship_dlvy_code = "20"
   or ship_dlvy_code = "O"
   then do:
      /* DAILY MONDAY-FRIDAY */
      resch_dt[1] = req_dt.
      if weekday(req_dt) = 7
      then
         resch_dt[1] = resch_dt[1] - 1.
      else
         if weekday(req_dt) = 1
         then
            resch_dt[1] = resch_dt[1] - 2.
   end. /* IF ship_dlvy_code = "20" */
   else
   if ship_dlvy_code = "21"
   or ship_dlvy_code = "Q"
   then do:
      /* TUESDAY *OR* THURSDAY */
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt - 7 + 3.
   end. /* IF ship_dlvy_code = "21" */
   else
   if ship_dlvy_code = "22"
   or ship_dlvy_code = "R"
   then do:
      /* WEDNESDAY *OR* FRIDAY */
      if req_dt >= wk_mon_dt + 4
      then
         resch_dt[1] = wk_mon_dt + 4.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
         resch_dt[1] = wk_mon_dt - 7 + 4.
   end. /* IF ship_dlvy_code = "22" */
   else
   if ship_dlvy_code = "23"
   or ship_dlvy_code = "U"
   then do:
      /* MONDAY *OR* WEDNESDAY */
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "23" */
   else
   if ship_dlvy_code = "24"
   then do:
      /* MONDAY *OR* THURSDAY */
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "24" */
   else
   if ship_dlvy_code = "25"
   then do:
      /* TUESDAY *OR* FRIDAY */
      if req_dt >= wk_mon_dt + 4
      then
         resch_dt[1] = wk_mon_dt + 4.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt - 7 + 4.
   end. /* IF ship_dlvy_code = "25" */
   else
   if ship_dlvy_code = "26"
   then do:
      /* MONDAY *OR* WEDNESDAY *OR* FRIDAY */
      if req_dt >= wk_mon_dt + 4
      then
         resch_dt[1] = wk_mon_dt + 4.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "26" */
   else
   if ship_dlvy_code = "27"
   then do:
      /* MONDAY *OR* TUESDAY *OR* WEDNESDAY *OR* THURSDAY */
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "27" */
   else
   if ship_dlvy_code = "28"
   then do:
      /* MONDAY *OR* TUESDAY *OR* THURSDAY */
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "28" */
   else
   if ship_dlvy_code = "29"
   then do:
      /* MONDAY *OR* WEDNESDAY *OR* THURSDAY */
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "29" */
   else
   if ship_dlvy_code = "30"
   then do:
      /* MONDAY *OR* TUESDAY *OR* WEDNESDAY *OR* FRIDAY */
      if req_dt >= wk_mon_dt + 4
      then
         resch_dt[1] = wk_mon_dt + 4.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt.
   end. /* IF ship_dlvy_code = "30" */
   else
   if ship_dlvy_code = "31"
   then do:
      /* TUESDAY *OR* WEDNESDAY *OR* THURSDAY *OR* FRIDAY */
      if req_dt >= wk_mon_dt + 4
      then
         resch_dt[1] = wk_mon_dt + 4.
      else
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt - 7 + 4.
   end. /* IF ship_dlvy_code = "31" */

   else
   if ship_dlvy_code = "32"
   then do:
      /* TUESDAY *OR* WEDNESDAY *OR* THURSDAY */
      if req_dt >= wk_mon_dt + 3
      then
         resch_dt[1] = wk_mon_dt + 3.
      else
      if req_dt >= wk_mon_dt + 2
      then
         resch_dt[1] = wk_mon_dt + 2.
      else
      if req_dt >= wk_mon_dt + 1
      then
         resch_dt[1] = wk_mon_dt + 1.
      else
         resch_dt[1] = wk_mon_dt - 7 + 3.
   end. /* IF ship_dlvy_code = "32" */
   else
   if ship_dlvy_code = "33"
   then do:
      /* DAILY MONDAY-SATURDAY*/
      resch_dt[1] = req_dt.
      if weekday(req_dt) = 1
      then
         resch_dt[1] = resch_dt[1] - 1.
   end. /* IF ship_dlvy_code = "33" */
   else
   if ship_dlvy_code = "34"
   then do:
      /* DAILY MONDAY-SUNDAY*/
      /* NO NEED TO ADJUST ANYTHING */
   end. /* IF ship_dlvy_code = "34" */

   else
   if ship_dlvy_code <> ""
   then

      resch_stat = getTermLabel("UNINTBLE_SHIP/DELIVERY_PTRN_CODE_OF",45) + " "
                 + ship_dlvy_code + " " + getTermLabel("FOR_DISCRETE_QUANTITY",25).
end. /* IF interval_code = "d" */

else
if interval_code = "w"
then do:
   /* HANDLE WEEKLY BUCKETED QUANTITIES */

   if ship_dlvy_code = "01"
   or ship_dlvy_code = "1"
   then do:
      /* 1ST WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt
      then
         resch_dt[1] = mth_1st_mon_dt.
      else
         resch_dt[1] = prior_mth_1st_mon_dt.
   end. /* IF ship_dlvy_code = "01" */
   else
   if ship_dlvy_code = "02"
   or ship_dlvy_code = "2"
   then do:
      /* 2ND WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt + 7
      then
         resch_dt[1] = mth_1st_mon_dt + 7.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 7.
   end. /* IF ship_dlvy_code = "02" */
   else
   if ship_dlvy_code = "03"
   or ship_dlvy_code = "3"
   then do:
      /* 3RD WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt + 14
      then
         resch_dt[1] = mth_1st_mon_dt + 14.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 14.
   end. /* IF ship_dlvy_code = "03" */
   else
   if ship_dlvy_code = "04"
   or ship_dlvy_code = "4"
   then do:
      /* 4TH WEEK OF MONTH */
      if req_dt >= mth_1st_mon_dt + 21
      then
         resch_dt[1] = mth_1st_mon_dt + 21.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 21.
   end. /* IF ship_dlvy_code = "04" */
   else
   if ship_dlvy_code = "05"
   or ship_dlvy_code = "6"
   then do:
      /* 1ST *OR* 3RD WEEKS OF MONTH */
      if req_dt >= mth_1st_mon_dt + 14
      then
         resch_dt[1] = mth_1st_mon_dt + 14.
      else
      if req_dt >= mth_1st_mon_dt
      then
         resch_dt[1] = mth_1st_mon_dt.
      else
      if req_dt >= prior_mth_1st_mon_dt + 14
      then
         resch_dt[1] = prior_mth_1st_mon_dt + 14.
      else
         resch_dt[1] = prior_mth_1st_mon_dt.
   end. /* IF ship_dlvy_code = "05" */
   else
   if ship_dlvy_code = "06"
   or ship_dlvy_code = "7"
   then do:
      /* 2ND *OR* 4TH WEEKS OF MONTH */
      if req_dt >= mth_1st_mon_dt + 21
      then
         resch_dt[1] = mth_1st_mon_dt + 21.
      else
      if req_dt >= mth_1st_mon_dt + 7
      then
         resch_dt[1] = mth_1st_mon_dt + 7.
      else
      if req_dt >= prior_mth_1st_mon_dt + 21
      then
         resch_dt[1] = prior_mth_1st_mon_dt + 21.
      else
         resch_dt[1] = prior_mth_1st_mon_dt + 7.
   end. /* IF ship_dlvy_code = "06" */
   else
   if ship_dlvy_code = "10"
   or ship_dlvy_code = "A"
   then do:
      /* MONDAY THRU FRIDAY */
      resch_dt[1] = req_dt.
      if weekday(req_dt) = 7
      then
         resch_dt[1] = resch_dt[1] - 1.
      else
         if weekday(req_dt) = 1
         then
            resch_dt[1] = resch_dt[1] - 2.
   end. /* IF ship_dlvy_code = "10" */
   else
   if ship_dlvy_code = "11"
   or ship_dlvy_code = "B"
   then do:
      /* MONDAY THRU SATURDAY */
      resch_dt[1] = req_dt.
      if weekday(req_dt) = 1
      then
         resch_dt[1] = resch_dt[1] - 1.
   end. /* IF ship_dlvy_code = "11" */
   else
   if ship_dlvy_code = "12"
   or ship_dlvy_code = "D"
   then do:
      /* MONDAY */
      days_of_week = "x      ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "12" */
   else
   if ship_dlvy_code = "13"
   or ship_dlvy_code = "E"
   then do:
      /* TUESDAY */
      days_of_week = " x     ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "13" */
   else
   if ship_dlvy_code = "14"
   or ship_dlvy_code = "F"
   then do:
      /* WEDNESDAY */
      days_of_week = "  x    ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "14" */
   else
   if ship_dlvy_code = "15"
   or ship_dlvy_code = "G"
   then do:
      /* THURSDAY */
      days_of_week = "   x   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "15" */
   else
   if ship_dlvy_code = "16"
   or ship_dlvy_code = "H"
   then do:
      /* FRIDAY */
      days_of_week = "    x  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "16" */
   else
   if ship_dlvy_code = "20"
   or ship_dlvy_code = "O"
   then do:
      /* DAILY MONDAY-FRIDAY */
      days_of_week = "xxxxx  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "20" */
   else
   if ship_dlvy_code = "21"
   or ship_dlvy_code = "Q"
   then do:
      /* TUESDAY AND THURSDAY */
      days_of_week = " x x   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "21" */
   else
   if ship_dlvy_code = "22"
   or ship_dlvy_code = "R"
   then do:
      /* WEDNESDAY AND FRIDAY */
      days_of_week = "  x x  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "22" */
   else
   if ship_dlvy_code = "23"
   or ship_dlvy_code = "U"
   then do:
      /* MONDAY AND WEDNESDAY */
      days_of_week = "x x    ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "23" */
   else
   if ship_dlvy_code = "24"
   then do:
      /* MONDAY AND THURSDAY */
      days_of_week = "x  x   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "24" */
   else
   if ship_dlvy_code = "25"
   then do:
      /* TUESDAY AND FRIDAY */
      days_of_week = " x  x  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "25" */
   else
   if ship_dlvy_code = "26"
   then do:
      /* MONDAY AND WEDNESDAY AND FRIDAY */
      days_of_week = "x x x  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "26" */
   else
   if ship_dlvy_code = "27"
   then do:
      /* MONDAY AND TUESDAY AND WEDNESDAY AND THURSDAY */
      days_of_week = "xxxx   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "27" */
   else
   if ship_dlvy_code = "28"
   then do:
      /* MONDAY AND TUESDAY AND THURSDAY */
      days_of_week = "xx x   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "28" */
   else
   if ship_dlvy_code = "29"
   then do:
      /* MONDAY AND WEDNESDAY AND THURSDAY */
      days_of_week = "x xx   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "29" */
   else
   if ship_dlvy_code = "30"
   then do:
      /* MONDAY AND TUESDAY AND WEDNESDAY AND FRIDAY */
      days_of_week = "xxx x  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "30" */
   else
   if ship_dlvy_code = "31"
   then do:
      /* TUESDAY AND WEDNESDAY AND THURSDAY AND FRIDAY */
      days_of_week = " xxxx  ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "31" */

   else
   if ship_dlvy_code = "32"
   then do:
      /* TUESDAY AND WEDNESDAY AND THURSDAY */
      days_of_week = " xxx   ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "32" */
   else
   if ship_dlvy_code = "33"
   then do:
      /* DAILY MONDAY-SATURDAY */
      days_of_week = "xxxxxx ".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "33" */
   else
   if ship_dlvy_code = "34"
   then do:
      /* DAILY MONDAY-SUNDAY */
      days_of_week = "xxxxxxx".
      {gprun.i ""rcsdpntb.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

      {gprun.i ""rcsdpntc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   end. /* IF ship_dlvy_code = "34" */

   else
   if ship_dlvy_code <> ""
   then

      resch_stat = getTermLabel("UNINTBLE_SHIP/DELIVERY_PTRN_CODE_OF",45) + " "
                 + ship_dlvy_code + " " + getTermLabel("FOR_WEEK_QUANTITY",25).
end. /* IF interval_code = "w" */

else
if interval_code = "m"
then do:
   /* HANDLE MONTHLY BUCKETED QUANTITIES */

   if ship_dlvy_code = "01"
   or ship_dlvy_code = "1"
   then
      /* 1ST WEEK OF MONTH */
      resch_dt[1] = mth_1st_mon_dt.
   else
   if ship_dlvy_code = "02"
   or ship_dlvy_code = "2"
   then
      /* 2ND WEEK OF MONTH */
      resch_dt[1] = mth_1st_mon_dt + 7.
   else
   if ship_dlvy_code = "03"
   or ship_dlvy_code = "3"
   then
      /* 3RD WEEK OF MONTH */
      resch_dt[1] = mth_1st_mon_dt + 14.
   else
   if ship_dlvy_code = "04"
   or ship_dlvy_code = "4"
   then
      /* 4TH WEEK OF MONTH */
      resch_dt[1] = mth_1st_mon_dt + 21.
   else
   if ship_dlvy_code = "05"
   or ship_dlvy_code = "6"
   then
      /* 1ST AND 3RD WEEKS OF MONTH */
      assign
         resch_ct     = 2
         resch_dt[1]  = mth_1st_mon_dt
         resch_qty[1] = round((req_qty / 2),0)
         resch_dt[2]  = mth_1st_mon_dt + 14
         resch_qty[2] = req_qty - resch_qty[1].
   else
   if ship_dlvy_code = "06"
   or ship_dlvy_code = "7"
   then
      /* 2ND AND 4TH WEEKS OF MONTH */
      assign
         resch_ct     = 2
         resch_dt[1]  = mth_1st_mon_dt + 7
         resch_qty[1] = round((req_qty / 2),0)
         resch_dt[2]  = mth_1st_mon_dt + 21
         resch_qty[2] = req_qty - resch_qty[1].
   else
   if ship_dlvy_code = "07"
   then
      /* FIRST DAY OF MONTH */
      resch_dt[1] = date(month(req_dt),1,year(req_dt)).
   else
   if ship_dlvy_code <> ""
   then

      resch_stat = getTermLabel("UNINTBLE_SHIP/DELIVERY_PTRN_CODE_OF",45) + " "
                 + ship_dlvy_code + " " + getTermLabel("FOR_MONTH_QUANTITY",25).

   do i = 1 to resch_ct:
      resch_dt[i] = resch_dt[i] + week_offset.
   end. /* DO i = 1 TO resch_ct */
end. /* IF interval_code = "m" */

else
if interval_code = "q"
then do:
   /* HANDLE QUARTERLY BUCKETED QUANTITIES */
   resch_ct = 3.
   {gprun.i ""rcsdpnta.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


   assign
      work_month = month(req_dt)
      work_year  = year(req_dt).
   do i = 1 to resch_ct:
      assign
         resch_dt[i] = date(work_month,1,work_year)
         work_month  = work_month + 1.

      if work_month > 12
      then
         assign
            work_month = 1
            work_year  = work_year + 1.
   end. /* DO i = 1 TO resch_ct */
end. /* IF interval_code = "q" */

else
if interval_code = "h"
then do:
   /* HANDLE HALF-YEARLY BUCKETED QUANTITIES */
   resch_ct = 6.
   {gprun.i ""rcsdpnta.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


   assign
      work_month = month(req_dt)
      work_year  = year(req_dt).

   do i = 1 to resch_ct:
      assign
         resch_dt[i] = date(work_month,1,work_year)
         work_month  = work_month + 1.

      if work_month > 12
      then
         assign
            work_month = 1
            work_year  = work_year + 1.
   end. /* DO i = 1 TO resch_ct */
end. /* IF interval_code = "h" */

else
if interval_code = "y"
then do:
   /* HANDLE YEARLY BUCKETED QUANTITIES */
   resch_ct = 12.
   {gprun.i ""rcsdpnta.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


   assign
      work_month = month(req_dt)
      work_year  = year(req_dt).

   do i = 1 to resch_ct:
      assign
         resch_dt[i] = date(work_month,1,work_year)
         work_month  = work_month + 1.

      if work_month > 12
      then
         assign
            work_month = 1
            work_year  = work_year + 1.
   end. /* DO i = 1 TO resch_ct */
end. /* IF interval_code = "y" */
